﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Framework;

namespace Enterprise.Admin.Handle
{
    public partial class RemoveWorkShopPicture : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            object result;
            try
            {
                var path = HttpContext.Current.Server.MapPath("~/Upload/WorkShop/");
                var normalImage = Fq("CoNormalImage").SafeToString();
                var smallImage = Fq("CoSmallImage").SafeToString();
                var bigImage = Fq("CoBigImage").SafeToString();
                FileHelper.DeleteSub(Path.Combine(path, normalImage));
                FileHelper.DeleteSub(Path.Combine(path, smallImage));
                FileHelper.DeleteSub(Path.Combine(path, bigImage));
                int id = Fq("CoWorkShopId").SafeToInt();
                var workShopService = new WorkShopService();
                workShopService.DeletePicture(id);
                result = (new { state = true, message = "删除成功！" });
            }
            catch (Exception ex)
            {
                result = (new { state = false, message = ex.Message });
            }
            Json(result);

        }
    }
}